<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>使用bootstrap绘制form表单</title>
<!-- Bootstrap core CSS -->
<link
	href="${pageContext.servletContext.contextPath}/static/plugins/bootstrap-3.3.7-dist/css/bootstrap.min.css"
	rel="stylesheet">
<link
	href="${pageContext.servletContext.contextPath}/static/plugins/bootstrap-3.3.7-dist/css/bootstrap-theme.min.css"
	rel="stylesheet">
<!-- Bootstrap core JavaScript-->
<!-- Placed at the end of the document so the pages load faster -->
<!--import jquery before bootstrap javascript-->
<script
	src="${pageContext.servletContext.contextPath}/static/plugins/jquery-1.12.4/jquery-1.12.4.min.js"></script>
<script
	src="${pageContext.servletContext.contextPath}/static/plugins/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>


<script type="text/javascript">
	$(function() {
		
		$("#btnSubmit").click(function(){
			$.ajax({
				// 请求类型
				   type: "POST",
					// 请求的url，和form的action属性值一样
				   url: "${pageContext.servletContext.contextPath}/CourseInfoAddControl",
					// 发送的表单数据，按照如下格式提供即可："name=John&location=Boston"
				  data:  $("#form1").serialize(), // 序列化表单参数，获取一个序列化的字符串，用于ajax请求，必须在form中才可以使用
				  //data:new FormData(document.forms[0]),
				   // response响应的数据类型，默认是文本类型，可以指定为 xml、html、json等类型
				   //dataType:"json",
				   // 回调函数
				   success: function(data, textStatus, jqXHR){
				     // 进行dom操作，局部修改浏览器的显示数据，进行局部刷新数据
					 if(data == "ok"){
						 alert("保存成功!");
						 $(location).attr('href', '${pageContext.servletContext.contextPath}/JumpU?pg=WEB-INF/pages/info/infoQuery.jsp');
						 
					 }else{
						 alert("保存失败!");
					 }
				   }
			});
			});
	});
</script>
	
<style>
#maindiv {
	width: 80%;
	padding-top: 10px;
}
</style>
</head>
<body>
	<div id="maindiv">
		<form id="form1" class="form-horizontal" >
			<div class="form-group">
				<label class="col-sm-2 control-label">课程名称</label>
				<div class="col-sm-4">
					<input type="text" class="form-control" id="courseName"
						name="c_Name" placeholder="请输入课程名称">
				</div>

				<label class="col-sm-2 control-label">课程内容</label>
				<div class="col-sm-4">
					<input type="text" class="form-control" id="courseContent"
						name="c_Con" placeholder="请输入课程内容">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">课程地点</label>
				<div class="col-sm-4">
					<input type="text" class="form-control" id="coursePlace"
						name="c_Place" placeholder="请输入课程名称">
				</div>

				<label class="col-sm-2 control-label">课程日期</label>
				<div class="col-sm-4">
					<input type="text" class="form-control" id="courseDate"
						name="c_Date"  placeholder="请输入课程日期">*输入格式为 年-月-日
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">课程时间</label>
				<div class="col-sm-4">
					<input type="text" class="form-control" id="courseTime"
						name="c_Time" placeholder="请输入课程时间">*输入具体哪节课
				</div>
			</div>

			<div class="form-group">
				<div class="col-sm-offset-2 col-sm-2">
					<button type="button" id="btnSubmit" class="btn btn-default">保存</button>
				</div>
				<div class="col-sm-offset-4 col-sm-2">
					<button type="reset" class="btn btn-default">重置</button>
				</div>
			</div>
		</form>
	</div>
</body>
</html>